﻿using System;

namespace DomainExample.DomainModel.ContactModel
{
    public sealed class Contact : IEntity
    {
        public ContactId Id { get; set; }
        public DateTime DateUtc { get; set; }
        public ContactType Type { get; set; }
        public DirectionType Direction { get; set; }
        public string Summary { get; set; }

        private Contact()
        {
            
        }

        public static Contact NewContact()
        {
            return NewContact(ContactId.NewContactId());
        }

        public static Contact NewContact(ContactId contactId)
        {
            return new Contact { Id = contactId };
        }

        public bool IsValidForPersistence()
        {
            return 
                DateUtc != DateTime.MinValue
                && Direction != null
                && Type != null;
        }

        public override string ToString()
        {
            return string.Format(
                "{0}: Id={1}, Date={2}, Type={3}, Direction={4}",
                base.ToString(),
                Id,
                DateUtc.ToString("yyyyMMdd"),
                Type,
                Direction
                );
        }
    }
}
